<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Get protocol number associated with protocol name</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.getprotobyname" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">getprotobyname</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">getprotobyname</span> &mdash; <span class="dc-title">Get protocol number associated with protocol name</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.getprotobyname-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>getprotobyname</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$name</code></span>
   ) : <span class="type">int</span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>getprotobyname()</strong></span> returns the protocol number
   associated with the protocol <code class="parameter">name</code> as per
   <var class="filename">/etc/protocols</var>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.getprotobyname-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">name</code></dt>

     <dd>

      <p class="para">
       The protocol name.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.getprotobyname-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns the protocol number,  或者在失败时返回 <strong><code>FALSE</code></strong>.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.getprotobyname-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-5488">
    <p><strong>Example #1 <span class="function"><strong>getprotobyname()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$protocol&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'tcp'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$get_prot&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">getprotobyname</span><span style="color: #007700">(</span><span style="color: #0000BB">$protocol</span><span style="color: #007700">);<br />if&nbsp;(</span><span style="color: #0000BB">$get_prot&nbsp;</span><span style="color: #007700">===&nbsp;</span><span style="color: #0000BB">FALSE</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">'Invalid&nbsp;Protocol'</span><span style="color: #007700">;<br />}&nbsp;else&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">'Protocol&nbsp;#'&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$get_prot</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.getprotobyname-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="getprotobynumber.html" class="function" rel="rdfs-seeAlso">getprotobynumber()</a> - Get protocol name associated with protocol number</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>